import request from '@/utils/request'
import { SysUser_URL } from '@/url/ihisOmpUrl'


/**
 * 分页查询
 * @param {*} page 
 * @param {*} size 
 * @param {*} searchMap 
 * @returns 
 */
export function search(page, size, searchMap) {
    return request({
        url: SysUser_URL + `/search/${page}/${size}`,
        method: "post",
        data: searchMap
    })
}

/**
 * 新增用户
 * @param {*} pojo 
 * @returns 
 */
export function add(pojo) {
    return request({
        url: SysUser_URL + '/add',
        method: 'post',
        data: pojo
    });
}


/**
 * 通过userKey查询用户信息
 * @param {*} userKey
 * @returns 
 */
export function getById(userKey) {
    return request({
        url: SysUser_URL + `/get/${userKey}`,
        method: 'get'
    });
}

/**
 * 更新用户信息
 * @param {*} pojo 
 * @returns 
 */
export function update(pojo) {
    return request({
        url: SysUser_URL + `/update/${pojo.userKey}`,
        method: 'post',
        data: pojo
    });
}


/**
 * 更新用户状态
 * @param {*} userKey 
 * @param {*} activeFlg 
 * @returns 
 */
export function updateStatus(userKey, activeFlg) {
    return request({
        url: SysUser_URL + `/status/${userKey}/${activeFlg}`,
        method: 'post'
    });
}

/**
 * 修改密码
 * @param {*} userKey 
 * @param {*} password 
 * @returns 
 */
export function updatePwd(userKey, password) {
    return request({
        url: SysUser_URL + '/updatePwd',
        method: 'post',
        data: {
            userKey,
            password
        }
    })
}
